/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.joseph.violation.plk;

/**
 * The principle states: 
 * Each unit should only talk to its friends; Don’t talk to strangers. 
 * A method of an object should invoke only the methods of 
 * the following kinds of objects: 
 *  1. itself 
 *  2. its parameters 
 *  3. any objects it creates/instantiates 
 *  4. its direct component objects
 *
 * @author Brad'ey
 */
public class OrderManager implements IOrderManager
{
	private IOrder _Order;

	public OrderManager()
	{
		_Order = new Order();
		_Order.Items = new List<IItem>();
	}

	public void AddItemToOrder(IItem item)
	{
		if (_Order.Items != null)
		{
			if ( ! _Order.Items.Contains(item))
			{
				_Order.Items.Add(item);
			}
		}
	}

	public void RemoveItemFromOrder(IItem item)
	{
		if (_Order.Items != null)
		{
			if (_Order.Items.Contains(item))
			{
				_Order.Items.Remove(item);
			}
		}
	}

	public void ChangeItemName(IItem item, string name)
	{
		if (_Order.Items != null)
		{
			if (_Order.Items.Contains(item))
			{
				_Order.Items[_Order.Items.IndexOf(item)].Name = name;
			}
		}
        }
}
